/****************************************************************
 * <strong>MFDataColumn虚拟化数据表</strong>
 *
 * <p>
 *MFDataColumn虚拟化数据表 
 * </p>
 *
 * @author AndyZhang 2011 cnet2001@163.com
 * @version 0.1
 * ToDo:2011-11-29 支持 BigTable
 ***************************************************************/
package com.thinkwide.data.ormapping.datatable;

import com.thinkwide.data.ormapping.enums.MFDataType;

public class MFDataColumn {
    private String field;
    private int index;
    private boolean visible;
    private boolean enable;
    private int resCode;
    private String title;
    private String width;
    private String template;
    private String headformat;
    private String tag;
    private String dataType;
    private MFDataType xdataType;
    private String dateFormat;
    private String defaultValue = "";
    private MFDefValueType defaultValueType;
    private Object data;
    private int length;
    private int Precision;
    private int Scale;
    private int wordSize = 0;
    private boolean allowNull;
    private MFDataColumns parent;
    private boolean primaryKey;
    private boolean indexKey;
    private String lookupid;
    private String format;
    private boolean allowSort;
    private MFDataColumnViewType viewType;

    public MFDataColumn() {
        primaryKey = false;
        indexKey = false;
        visible = true;
        enable = true;
        allowNull = true;
        allowSort = true;
        viewType = MFDataColumnViewType.text;
    }

    public MFDataColumn(String field) {
        this();
        this.field = field;
    }

    public MFDataColumn(String field, String title) {
        this(field);
        this.title = title;
    }

    public MFDataColumn(String field, String title, String dataType) {
        this(field);
        this.field = field;
        this.title = title;
        this.dataType = dataType;
    }

    public MFDataColumn(String field, String title, String width, MFDataColumnViewType viewType) {
        this(field);
        this.field = field;
        this.title = title;
        this.width = width;
        this.viewType = viewType;
    }

    public MFDataColumn(String field, String title, String width, MFDataColumnViewType viewType, String lookupid) {
        this(field);
        this.field = field;
        this.title = title;
        this.width = width;
        this.viewType = viewType;
        this.lookupid = lookupid;
    }

    public MFDataColumn(String field, String title, MFDataColumnViewType viewType) {
        this(field);
        this.field = field;
        this.title = title;
        this.viewType = viewType;
    }

    public MFDataColumn(String field, String title, MFDataColumnViewType viewType, String lookupid) {
        this(field);
        this.field = field;
        this.title = title;
        this.viewType = viewType;
        this.lookupid = lookupid;
    }

    public MFDataColumn(MFDataColumnViewType viewType, String title, String width, String format) {
        this();
        this.title = title;
        this.width = width;
        this.viewType = viewType;
        this.format = format;
    }

    public MFDataColumn(String field, String title, String width, String format) {
        this(field);
        this.field = field;
        this.title = title;
        this.width = width;
        this.format = format;
    }

    public static MFDataColumn clone(MFDataColumn column) {
        MFDataColumn col = new MFDataColumn();
        col.setAllowNull(column.isAllowNull());
        col.setData(column.getData());
        col.setDataType(column.getDataType());
        col.setEnable(column.getEnable());
        col.setField(column.getField());
        col.setFormat(column.getFormat());
        col.setHeadformat(column.getHeadformat());
        col.setIndex(column.getIndex());
        col.setLength(column.getLength());
        col.setLookupid(column.getLookupid());
        col.setPrimaryKey(column.isPrimaryKey());
        col.setResCode(column.getResCode());
        col.setTag(column.getTag());
        col.setTemplate(column.getTemplate());
        col.setTitle(column.getTitle());
        col.setTemplate(column.getTemplate());
        col.setViewType(column.getViewType());
        col.setVisible(column.getVisible());
        col.setWidth(column.getWidth());

        return col;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String getField() {
        return field;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public String getDataType() {
        return dataType;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getLength() {
        return length;
    }

    public void setAllowNull(boolean allowNull) {
        this.allowNull = allowNull;
    }

    public boolean isAllowNull() {
        return allowNull;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    public String getWidth() {
        return width;
    }

    public void setTemplate(String template) {
        this.template = template;
    }

    public String getTemplate() {
        return template;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public int getIndex() {
        if (parent != null) parent.indexOf(this);
        return index;
    }

    public void setParent(MFDataColumns parent) {
        this.parent = parent;
    }

    public MFDataColumns getParent() {
        return parent;
    }

    public void setResCode(int resCode) {
        this.resCode = resCode;
    }

    public int getResCode() {
        return resCode;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public boolean getEnable() {
        return enable;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    public boolean getVisible() {
        return visible;
    }

    public void setPrimaryKey(boolean primaryKey) {
        this.primaryKey = primaryKey;
    }

    public boolean isPrimaryKey() {
        return primaryKey;
    }

    public void setIndexKey(boolean indexKey) {
        this.indexKey = indexKey;
    }

    public boolean isIndexKey() {
        return indexKey;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Object getData() {
        return data;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public String getTag() {
        return tag;
    }

    public void setFormat(String format) {
        this.format = format;
    }

    public String getFormat() {
        return format;
    }

    public void setViewType(MFDataColumnViewType viewType) {
        this.viewType = viewType;
    }

    public MFDataColumnViewType getViewType() {
        return viewType;
    }

    public void setHeadformat(String headformat) {
        this.headformat = headformat;
    }

    public String getHeadformat() {
        return headformat;
    }

    public void setLookupid(String lookupid) {
        this.lookupid = lookupid;
    }

    public String getLookupid() {
        return lookupid;
    }

    public void setAllowSort(boolean allowSort) {
        this.allowSort = allowSort;
    }

    public boolean isAllowSort() {
        return allowSort;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDateFormat(String dateFormat) {
        this.dateFormat = dateFormat;
    }

    public String getDateFormat() {
        return dateFormat;
    }

    public void setXdataType(MFDataType xdataType) {
        this.xdataType = xdataType;
    }

    public MFDataType getXdataType() {
        return xdataType;
    }

    public void setPrecision(int precision) {
        Precision = precision;
    }

    public int getPrecision() {
        return Precision;
    }

    public void setScale(int scale) {
        Scale = scale;
    }

    public int getScale() {
        return Scale;
    }

    public void setWordSize(int wordSize) {
        this.wordSize = wordSize;
    }

    public int getWordSize() {
        return wordSize;
    }

    public void setDefaultValueType(MFDefValueType defaultValueType) {
        this.defaultValueType = defaultValueType;
    }

    public MFDefValueType getDefaultValueType() {
        return defaultValueType;
    }
}
